package com.xianrenit.xianrenpuzi.manager.util;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Data
@ConfigurationProperties(prefix = "spzx.minio")
@Configuration
public class SpzxMinioProperties implements InitializingBean {
    private String endpoint;//: http://192.168.1.170:9000
    private String accessKey;//: admin
    private String secretKey;//: admin123456
    private String bucketName;//: test2-bucket

    //类被加载时，静态属性也会初始化，默认都是null
    //当容器初始化当前类的对象时，会初始化属性值。如果可以在容器初始化对象属性值以后 将属性值赋值给自己类的静态属性
    //spring提供了bean的生命周期方法：可以在容器初始化对象后去调用某个生命周期方法
    @Override
    public void afterPropertiesSet() throws Exception {
        ENDPOINT = this.getEndpoint();
        ACCESS_KEY = this.getAccessKey();
        SECRET_KEY = this.getSecretKey();
        BUCKET_NAME = this.getBucketName();
    }
    public static String ENDPOINT;//: http://192.168.1.170:9000
    public static String ACCESS_KEY;//: admin
    public static String SECRET_KEY;//: admin123456
    public static String BUCKET_NAME;//: test2-bucket



    //我希望不使用自动装配也能使用配置常量类中的属性


}
